<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="/WEB-INF/webpage/common/taglibs.jspf"%>
<!DOCTYPE html>
<html>
<head>
    <title>分公司进度情况</title>
    <meta name="decorator" content="form"/>
    <html:css name="bootstrap-fileinput" />
    <html:css name="simditor,jquery-select2" />
    <html:js name="jquery-select2"/>
</head>

<body class="white-bg"  formid="xmglFilialeProgressForm">
    <form:form id="xmglFilialeProgressForm" modelAttribute="data" action="${adminPath}/xmgl/xmglfilialeprogress/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<form:hidden path="filiale"/>
		<table  class="table table-bordered  table-condensed dataTables-example dataTable no-footer">
		    <tbody>
				<tr>
					<td  class="width-15 active text-right">	
		              <label><font color="red">*</font>分公司:</label>
		            </td>
					<td class="width-35">
						<form:select path="filialeCode" htmlEscape="false" class="form-control"        />
						<label class="Validform_checktip"></label>
					</td>
					<td  class="width-15 active text-right">	
		              <label><font color="red">*</font>实际完成量:</label>
		            </td>
					<td class="width-35">
						<form:input path="fact" htmlEscape="false" class="form-control"      />
						<label class="Validform_checktip"></label>
					</td>
				</tr>
				<tr>
					<td  class="width-15 active text-right">	
		              <label><font color="red">*</font>计划量:</label>
		            </td>
					<td class="width-35">
						<form:input path="plan" htmlEscape="false" class="form-control"      />
						<label class="Validform_checktip"></label>
					</td>
					<td  class="width-15 active text-right">	
		              <label>备注信息:</label>
		            </td>
					<td class="width-35">
						<form:input path="remarks" htmlEscape="false" class="form-control"      />
						<label class="Validform_checktip"></label>
					</td>
		  		</tr>
		      
		   </tbody>
		</table>   
	</form:form>
<html:js name="bootstrap-fileinput" />
<html:js name="simditor" />
<script>
var filiale="";
$(function() {
	getSelectFiliale(); 
	
})



//绑定分公司
function getSelectFiliale() {
	filiale = $("#filiale").val();
	$("#filialeCode").change(function(){
		$("#filiale").val($("#filialeCode").find("option:selected").text());
		console.log("filiale:"+$("#filiale").val());
	});
    $.ajax({
        type: "POST",
        url: "${adminPath}/xmgl/xmglfiliale/ajaxList",
        data: {'page.size':100,queryFields:'id,name,'},
        dataType: "json",
        success: function (data) {
            var select = $("#filialeCode");
        	
            select.empty();
        	if(data && data.total>0){            	
                var str = "<option value=''>请选择</option>";
                select.append(str);
                if (null != data && data.results.length > 0) {
                    $.each(data.results, function (i, item) {
                        if(filiale && item.id==filiale){
                            str = "<option value=" + item.id + " selected>" + item.name + "</option>";
                            select.append(str);
                            var event = document.createEvent("HTMLEvents");
                            event.initEvent("change", true, true);
                            document.querySelector("#filialeCode").dispatchEvent(event);
                        }else{
                            str = "<option value=" + item.id + ">" + item.name + "</option>";
                            select.append(str);
                        }
                    });
                } else {
                    console.log("data is null");
                }
        	}

        }
    });
}
</script>
</body>
</html>